#include "stdafx.h"
#include "Breakpoint.h"

HRESULT __stdcall CreateBreakpoint( IBreakpoint **ppOut )
{
    return CBreakpoint::Create( ppOut );
}

HRESULT CBreakpoint::Create( IBreakpoint **ppOut )
{
    if( !ppOut )
        return E_POINTER;

    typedef CComObject<CBreakpoint> TCBreakpoint;
    TCBreakpoint *p = NULL;
    HRESULT hr = TCBreakpoint::CreateInstance( &p );
    if( SUCCEEDED( hr ) )
    {
        p->AddRef();
        hr = p->QueryInterface( IID_IBreakpoint, (void**)ppOut );
        p->Release();
    }

    return hr;
}

CBreakpoint::CBreakpoint()
{
    m_bActive    = FALSE;
    m_dwIP       = 0;
    m_dwHitCount = 0;
    m_dwLineIdx  = -1;
}

CBreakpoint::~CBreakpoint()
{

}

STDMETHODIMP CBreakpoint::SetIP(DWORD dwIP)
{
    m_dwIP = dwIP;
    return S_OK;
}

STDMETHODIMP_(DWORD) CBreakpoint::GetIP()
{
    return m_dwIP;
}

STDMETHODIMP CBreakpoint::SetLineIndex( DWORD dwIdx )
{
    m_dwLineIdx = dwIdx;
    return S_OK;
}

STDMETHODIMP_(DWORD) CBreakpoint::GetLineIndex()
{
    return m_dwLineIdx;
}


STDMETHODIMP CBreakpoint::SetActive(BOOL bActive)
{
    m_bActive = bActive;
    return S_OK;
}

STDMETHODIMP_(BOOL) CBreakpoint::GetActive()
{
    return m_bActive;
}

STDMETHODIMP CBreakpoint::Hit()
{
    m_dwHitCount++;
    return S_OK;
}

STDMETHODIMP_(DWORD) CBreakpoint::GetHitCount()
{
    return m_dwHitCount;
}
